package me.zhengjie.modules.system.repository;

import me.zhengjie.modules.system.domain.Dict;
import me.zhengjie.modules.system.domain.DictDetail;
import me.zhengjie.modules.system.service.dto.DictDetailDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

/**
* @author Zheng Jie
* @date 2019-04-10
*/
public interface DictDetailRepository extends JpaRepository<DictDetail, Long>, JpaSpecificationExecutor {
    //  @Query(value = "select a.* from dict_detail a where dict_detail=?1")
    @Query("select t from DictDetail t where t.dict.id = ?1")
    List<DictDetail> findByDictIdInfo(Long  dictId);

    @Query("select t from DictDetail t where t.dict.id = ?1 and (t.label = ?2 or t.value = ?3)")
    List<DictDetail> findByDictIdAndLabelOrValue(Long dictId, String label, String value);

    List<DictDetail> findByDictIdAndLabel(Long dictId, String label);
}